<template>
    <div class="wrapper" ref="wrapper">
        <div>
            <slot></slot>
        </div>
    </div>
</template>

<script>
import BetterScroll from 'better-scroll'

export default {
    props:{
        probeType:{
            type:Number
        },
        pullUpLoad:{
            type:Boolean,
            default: false
        }
    },
    data () {
        return {
            scroll:null
        } 
    },
    mounted(){
        // 1.创建bscroll对象
        this.scroll = new BetterScroll(this.$refs.wrapper, {
            //  wheel: true,
            scrollbar: true,
            ObserveDom:true,
            click:true, 
            probeType:this.probeType,
            pullUpLoad: this.pullUpLoad,

    })  
    //监听滚动的位置
    this.scroll.on('scroll',(position)=>{
        // console.log(position);
        this.$emit('scrollTop',position)
    })
        if(this.pullUpLoad){
      this.scroll.on('pullingUp', ()=>{
      this.$emit('pullingUp');
    })
    }
    },
    methods: {
        scrollTo(x,y,time=500){
            this.scroll&&this.scroll.scrollTo(x,y,time)
        },
        finishPullUp(){
      this.scroll.finishPullUp();
    },
        refresh(){
            console.log('---');
            this.scroll&&this.scroll.refresh()
        }
    }

    // 
};
</script>

<style lang="less" scoped>


</style>

